<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <link rel="stylesheet" th:href="@{/layui/css/layui.css}" media="all">
</head>
<body>
<div class="layui-container" style="width: 960px;height: 600px;margin-top: 0px;padding-top: 60px;">

    <table class="layui-hide" id="test" lay-filter="test"></table>
    <script th:src="@{/layui/layui.js}" charset="utf-8"></script>
    <script>
        layui.use('table', function () {
            var table = layui.table;

            table.render({
                elem: '#test'
                , url: '/order/findAll'
                , title: '订单列表'
                , cols: [
                    [
                        {field: 'id', width: 80, title: '编号',sort:true }
                        , {
                        field: 'name', width: 120, title: '商品', templet: function (data) {
                            return data.commodity.name
                        }
                    }
                        , {
                        field: 'price', width: 80, title: '单价', templet: function (data) {
                            return data.commodity.price
                        }
                    }
                        , {
                        field: 'nickname', width: 80, title: '用户', templet: function (data) {
                            return data.user.nickName
                        }
                    }
                        , {
                        field: 'telephone', width: 140, title: '联系电话', templet: function (data) {
                            return data.user.telephone
                        }
                    }
                        , {
                        field: 'address', width: 140, title: '地址', templet: function (data) {
                            return data.user.address
                        }
                    }
                        , {field: 'date', width: 200, title: '下单时间'}
                        , {field: 'state', width: 160, title: '订单状态', templet: function (data) {
                            var result = "";
                            switch (data.state) {
                                case 0:
                                    result = "未派送";
                                    break;
                                case 1:
                                    result = "已派送";
                                    break;
                            }
                            return result
                    }
                   }
                   ]
                    ]
                , page: true
            });

        });
    </script>

</div>
<script>
    //二级菜单联动
    layui.use('element', function () {
        var element = layui.element;

    });
</script>
</body>
</html>